﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Ignitron.EEngine.Maths;
namespace Board3D.Animation
{
    /// <summary>
    /// Class for calculation of Hermit curve
    /// </summary>
    internal static class Hermite
    {
        private static float H0(float u)
        {
            return (2 * u * u * u - 3 * u * u + 1);
        }

        private static float H1(float u)
        {
            return (-2 * u * u * u + 3 * u * u);
        }

        private static float H2(float u)
        {
            return (u * u * u - 2 * u * u + u);
        }

        private static float H3(float u)
        {
            return (u * u * u - u * u);
        }

        public static EVector3 Calculate(EVector3 startPoint, EVector3 startTangent,
                EVector3 endPoint, EVector3 endTangent, float delta)
        {
            return H0(delta) * startPoint + H1(delta) * endPoint + H2(delta) * startTangent + H3(delta) * endTangent;
        }                      
    }
}
